const dgram =require('dgram');
const client = dgram.createSocket('udp4');

// process.stdin.resume();

// //通过stdin接受用户输入数据
// process.stdin.on('data', function(data){
//     client.send(data, 0, data.length, 4000, 'localhost');
// })
client.on("listening", () => {
    console.log("listening");
})


client.on('message',(msg)=>{
    console.log('我收到了服务端发送的消息！')
    console.log('msg: ', msg.toString());
    client.send(`hello,I am client`,4000,'localhost');
})

client.on("close", () => {
    console.log("socket已经关闭");
})

client.bind(5000,"127.0.0.1")

